import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3

Item {

    ListModel
        {
            id: tableModel

            ListElement
            {
                checked: false
                color: "blue"
            }

            ListElement
            {
                checked: true
                color: "green"
            }

            ListElement
            {
                checked: false
                color: "red"
            }
        }

        TableView
        {
            id: tableView
anchors.fill: parent
anchors.margins: 1
            model: tableModel

            TableViewColumn
            {
                id: checkedColumn
                role: "checked"
                title: qsTr( "Checked" )
            }

            TableViewColumn
            {
                role: "color"
                title: qsTr( "Color" )
            }

            itemDelegate: Item
            {
                CheckBox
                {
                    //anchors.centerIn: parent
                    checked: styleData.value
                    visible: isCheckColumn( styleData.column )
                }

                Text
                {
                    //anchors.left: parent.left
                    //anchors.verticalCenter: parent.verticalCenter
                    text: styleData.value
                    color: isCheckColumn( styleData.column )? "black": styleData.value
                    visible: !isCheckColumn( styleData.column )
                }

                function isCheckColumn( columnIndex )
                {
                    return tableView.getColumn( columnIndex ) === checkedColumn
                }
            }
        }
}
